package com.nwpu.server.admin.app;

import java.util.Arrays;
import java.util.Map;

import com.nwpu.server.admin.entity.MethodEntity;
import com.nwpu.server.admin.service.MethodService;
import com.nwpu.server.common.response.PageUtils;
import com.nwpu.server.common.response.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * 
 *
 * @author YuXingZh
 * @email 617058979@qq.com
 * @date 2022-04-23 20:17:11
 */
@RestController
@RequestMapping("admin/method")
public class MethodController {
    @Autowired
    private MethodService methodService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = methodService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		MethodEntity method = methodService.getById(id);

        return R.ok().put("method", method);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MethodEntity method){
		methodService.save(method);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MethodEntity method){
		methodService.updateById(method);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		methodService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
